package com.eystar.pdc.model;

import java.util.List;

import com.eystar.ext.kit.page.PageOrder;
import com.eystar.ext.plugin.tablebind.ModelExt;
import com.eystar.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.SqlPara;

import cn.hutool.core.util.StrUtil;

@TableBind(tableName = "t_pdc_user")
public class User extends ModelExt<User> {

	private static final long serialVersionUID = 3569673336161592702L;
	public final static User dao = new User();
	
	/**
	 * 分页查找对象
	 * @param order
	 * @param user
	 * @return
	 */
	public Page<User> paginate(PageOrder order, User user) {
		SqlPara sqlPara = getSqlPara("pdc.user.paginate",user,order);
		return paginate(order.getPageNum(), order.getPageSize(), sqlPara);
	}
	
	/**
	 * 根据角色ids查找用户
	 * @param ids
	 * @return
	 */
	public List<User> findUserByRoloIds(String ids){
		Kv kv = Kv.by("ids", StrUtil.split(ids, ","));
		SqlPara sqlPara = getSqlPara("pdc.user.findUserByRoloIds", kv);
		return find(sqlPara);
	}
	
	public String getSalt() {
		return getStr("user_salt");
	}
}
